#ifndef _COMMON_H
#define _COMMON_H

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#define RIGHT 		0
#define RIGHT_TOP 	1
#define TOP		2
#define LEFT_TOP	3
#define LEFT 		4
#define LEFT_BOT 	5
#define BOT		6
#define RIGHT_BOT	7
#define NUM_DIR		8

#define VERTICAL    2
#define BDIAGONAL   3
#define HORIZONTAL  4
#define FDIAGONAL   5

// character types
#define UPPER 	0
#define NORM 	1
#define LOWER 	2

#define PI 3.14159


typedef struct {
    int h;
    int w;
    unsigned char** pixels;
} Image;

typedef struct {
    int h;
    int w;
    unsigned int** pixels;
} IntegralImage;

typedef struct {
    int x;
    int y;
    int w;
    int h;
} Rect;

typedef unsigned short PIXEL;

/** Image function */
Image createImage(int h, int w);
IntegralImage createIntegralImage(int h, int w);
void copyImage(Image dst, Image src);
int inImage(int y, int x, int h, int w);
int getNeighbor(Image input, int dir, int x, int y);
int getNeighborForMatch(Image input, int dir, int x, int y);
void setNeighbor(Image input, int dir, int x, int y, int val);
void printImage(Image input, char* fileName);
void printFeatureImage(Image input, char* fileName);
void deleteImage(Image input);

/** Rect function */
void setRect(Rect *rect, int x, int y, int w, int h);
void addPointToRect(Rect *rect, int x, int y);

#endif
